<template>
  <div class="yz">
    <types-tag :list="list">CF手游</types-tag>
  </div>
</template>
<script>
import { getRoom, getRoomCopy } from "../utils/api/http";
import types from "../components/types";
export default {
  data() {
    return {
      page: 1,
      nowPage: 2,
      list: [],
    };
  },
  components: {
    typesTag: types,
  },
  methods: {
    scrollEvent() {
      var a = document.documentElement.scrollTop;
      var b = document.documentElement.clientHeight;
      var c = document.documentElement.scrollHeight;
      if (c - a - b < 1) {
          this.nowPage++
          this.getData();
      }
    },
    getData() {
      getRoomCopy(this.nowPage, this.$route.query.type).then((res) => {
        this.list = [...this.list, ...res.data.data.list];
      });
    },
  },
  mounted() {
    document.addEventListener("scroll", this.scrollEvent);
  },
  created() {
    getRoom(this.page, this.$route.query.type).then((res) => {
      this.list = res.data.data.list;
      this.getData();
    });
  },
};
</script>